package com.aurora.oa.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.aurora.oa.mycenter.view.MessageSendSetting;

/**
 * Created by Administrator on 2017/3/17 0017.
 */
public class SharedPreferencesUtil {

    public static final String IS_MESSAGE_NOTICE = "is_message_notice";
    public static final String USER_NAME="user_name";
    public static final String PASS_WORD="pass_word";
    public static final String SIGN_DATE="sign_date";
    public static final String SP_NAME="aurora_oa_sp";
    //自动登录令牌
    public static final String TOKEN = "token";
    public static final String IS_GESTURE_OPEN ="is_gesture_open";
    public static final String GESTURE_PASSWORD = "gesture_password";
    static SharedPreferences sp;



    public static void saveString(Context context,String key,String value) {
        if(sp==null){
            sp= context.getSharedPreferences(SP_NAME,context.MODE_PRIVATE);
        }

        SharedPreferences.Editor edit = sp.edit();
        edit.putString(key,value);
        edit.commit();

    }

    public static String getString(Context context,String key) {
        if(sp==null){
            sp= context.getSharedPreferences(SP_NAME,context.MODE_PRIVATE);
        }

        return sp.getString(key,"");
    }

    public static boolean getBoolean(Context context, String key,boolean defaultValue) {
        if(sp==null){
            sp= context.getSharedPreferences(SP_NAME,context.MODE_PRIVATE);
        }
        return sp.getBoolean(key,defaultValue);
    }

    public static void saveBoolean(Context context,String key,boolean value) {
        if(sp==null){
            sp= context.getSharedPreferences(SP_NAME,context.MODE_PRIVATE);
        }

        SharedPreferences.Editor edit = sp.edit();
        edit.putBoolean(key,value);
        edit.commit();

    }
}
